package com.doctcloud.datacloud.entity;

import com.baomidou.mybatisplus.annotation.TableName;
import com.doctcloud.common.core.annotation.Excel;
import com.doctcloud.common.core.annotation.NotZero;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.*;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Positive;
import java.io.Serializable;
import java.util.Date;

import static com.doctcloud.common.core.utils.NumberUtils.processNumber;
import static com.doctcloud.common.core.utils.StringUtils.trim;
@Data
@AllArgsConstructor
@NoArgsConstructor
@ToString
@EqualsAndHashCode(of = {"visitDate","visitNo","itemNo"})
@TableName("outp_bill_items")
public class OutpBillItemsEntity implements Serializable {
    private static final long serialVersionUID = 1L;
    @Excel(name="就诊时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @NotNull
    private Date visitDate;
    @Excel(name="就诊序号")
    @NotZero(message = "就诊序号不得为空或0")
    private Integer visitNo;
    @Excel(name = "收费单据号")
    @NotBlank(message = "收费单据号不得为空")
    private String rcptNo;
    @Excel(name = "项目序号")
    @Positive(message = "项目序号必须大于零")
    private Integer itemNo;
    @Excel(name = "项目类别")
    @NotBlank(message = "项目类别不得为空")
    private String itemClass;
    @Excel(name = "项目代码")
    @NotBlank(message = "项目代码不得为空")
    private String itemCode;
    @Excel(name = "项目名称")
    @NotBlank(message = "项目名称不得为空")
    private String itemName;
    @Excel(name = "项目规格")
    @NotBlank(message = "项目规格不得为空")
    private String itemSpec;
    @Excel(name = "项目单位")
    private String units;
    @Excel(name = "数量")
    @NotZero(message = "数量不得为零或为空")
    private Integer amount;
    @Excel(name = "计价金额")
    @NotNull(message = "计价金额")
    private Double costs;
    @Excel(name = "应收金额")
    @NotNull(message = "应收金额")
    private Double charges;
    public void setRcptNo(String rcptNo) {
        this.rcptNo = trim(rcptNo);
    }

    public void setItemClass(String itemClass) {
        this.itemClass = trim(itemClass);
    }

    public void setItemCode(String itemCode) {
        this.itemCode = trim(itemCode);
    }

    public void setItemName(String itemName) {
        this.itemName = trim(itemName);
    }

    public void setItemSpec(String itemSpec) {
        this.itemSpec = trim(itemSpec);
    }

    public void setAmount(Integer amount) {
        this.amount = processNumber(amount,0);
    }

    public void setCosts(Double costs) {
        this.costs = processNumber(costs,0.0);
    }

    public void setCharges(Double charges) {
        this.charges = processNumber(charges,0.0);
    }
}
